package com.woniuxy.day10springmvc4;


import com.woniuxy.day10springmvc4.entity.Student;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

@Controller
public class UserManager {

    @PostMapping("/user")
    public void addOne(@RequestBody Student user){
        System.out.println("UserManager.addOne"+user);
    }
    //对应前端的请求就是/user/1/2
    @GetMapping("/user/{uid}/{id}")
    public UserManager findOne(@PathVariable("id") int id,@PathVariable("uid") int uid) {
        System.out.println("UserManager.findOne:"+id+"-----------"+uid);
        return null;
    }
    //对应前端的请求就是/user/1/2
    @GetMapping("/user/{id}")
    public UserManager findOne(@PathVariable("id") int id) {
        System.out.println("UserManager.findOne:"+id+"-----------");
        return null;
    }
    @PutMapping("/user/{id}")
    public String updateOne(@PathVariable int id, Student user, Model model) {
        model.addAttribute("msg",user);
        System.out.println("UserManager.updateOne"+user+"_---"+id);
        return "/WEB-INF/success.jsp";
    }
    @DeleteMapping("/user/{id}")
    public void deleteOne(@PathVariable int id){
        System.out.println("UserManager.deleteOne"+id);
    }
}
